<?php
/**
 * Created by PhpStorm.
 * User: yuanjie
 * Date: 2017/3/3
 * Time: 下午2:36
 */

$api_service_path = __DIR__ . "/../../../api/";
ob_start();
require_once($api_service_path . "public/index.php");
ob_end_clean();

$date = date('Ymd',time());
$report = array();
$mail = array(
    'yuanjie@anhuibj.com',
//    'husheng@anhuibj.com',
);

$file_list = array(
    './1.pid',
    './2.pid'
);

$time_diff = 60*15; //15分钟

foreach ($file_list as $_file){
    if(file_exists($_file)){
        $ctime=filectime($_file);
            if((time() - $ctime) >=  $time_diff){
                $report_data = array(
                    'mail' => $mail,
                    'name' => '服务器自动进程报警',
                    'date' => $date,
                    'data' => $_file
                );

                Mail::send('check_pid_mail',$report_data, function($message) use ($report_data){
                    $message->to($report_data['mail'], $report_data['name'])->subject($report_data['name']);
                });
            }
    }
}